
private ["_building","_player_pos","_building_type","_relative_pos","_position_type","_params"];
_building = nearestObject [player, "Building"];
If (isNil "D_LAST_BUILDING_TYPE") then {D_LAST_BUILDING_TYPE = ""};
If (isNil "D_LAST_BUILDING_POS") then {D_LAST_BUILDING_POS = ""};
If (!isNil "_building") then {
	_player_pos = getPosAsl player;
	_building_pos = getPosAsl _building;
	// _player_pos = getPos player;
	// _building_pos = getPos _building;
	_building_type = typeOf _building;
	// This doesn't work for roof positions... when you try to modelToWorld back.
	// _relative_pos = _building worldToModel _player_pos;
	
	_params = _this select 3;
	_position_type = _params select 0;

	_px = _player_pos select 0;
	_py = _player_pos select 1;
	_pz = _player_pos select 2;
	
	_bx = _building_pos select 0;
	_by = _building_pos select 1;
	_bz = _building_pos select 2;
	
	_relative_pos = [_px - _bx,_py - _by, _pz - _bz];
	
	diag_log format["%1,%2,%3,%4",str(_building_type),(_position_type -1),_relative_pos,getDir player];
	player GlobalChat Format["Type: %1  Pos:%2  Rel:%3",_building_type,_position_type,_relative_pos];
} else {
	player GlobalChat "No building near you";
};

